<?php


namespace part16_StateMode\Code4;

/**
 * 工作类，此时没有了过长的分支判断语句
 */
class Work
{
    private $current;
    private $hour;
    private $finish = false;

    public function __construct()
    {
        // 初始化为上午工作状态
        $this->current = new ForenoonState();
    }

    public function setHour($hour)
    {
        $this->hour = $hour;
    }

    public function getHour()
    {
        return $this->hour;
    }


    public function setFinished($finished)
    {
        $this->finish = $finished;
    }

    public function getFinished()
    {
        return $this->finish;
    }

    /**
     * @param $s State
     */
    public function setState($s)
    {
        $this->current = $s;
    }

    public function writeProgram()
    {
        $this->current->writeProgram($this);
    }
}